package com.cskaoyan.service;

import com.cskaoyan.bean.statVo.*;
import com.cskaoyan.mapper.MarketUserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author Austin Hsu
 * @Date 2022/9/7 21:50
 */

@Service
public class StatServiceImpl implements StatService {

    @Autowired
    MarketUserMapper userMapper;


    /**
     * 统计User
     * sql: select
     * @return
     */
    @Override
    public StatUserVo queryUser() {
        StatUserVo statUserVo=new StatUserVo();

        ArrayList<String> list1 = new ArrayList<>();          //列
        list1.add("day");
        list1.add("users");
        statUserVo.setColumns(list1);

        List<StatUserRowsVo> list=userMapper.queryUser();     //行
        statUserVo.setRows(list);

        return statUserVo;
    }

    @Override
    public StatGoodsVo queryGoods() {
        StatGoodsVo statGoodsVo=new StatGoodsVo();

        ArrayList<String> list1 = new ArrayList<>();          //列
        list1.add("day");
        list1.add("orders");
        list1.add("products");
        list1.add("amount");
        statGoodsVo.setColumns(list1);

        List<StatGoodsRowsVo> list=userMapper.queryGoods();
        statGoodsVo.setRows(list);


        return statGoodsVo;
    }

    @Override
    public StatOrderVo queryOrder() {
        StatOrderVo statOrderVo=new StatOrderVo();

        ArrayList<String> list1 = new ArrayList<>();          //列
        list1.add("day");
        list1.add("orders");
        list1.add("customers");
        list1.add("amount");
        list1.add("pcr");
        statOrderVo.setColumns(list1);

        List<StatOrderRowsVo> list=userMapper.queryOrder();
        statOrderVo.setRows(list);


        return statOrderVo;
    }
}
